Repository navigation
Conversation
aleksisch
force-pushed
the
aleksisch/dasllama-load-leaks
branch
2 times, most recently
from
November 25, 2026 13:09
9704ad2 to
8826ed9
Compare
layout_describe built the meta closure's description with += on a string: each append copies the whole description, and the copies stay on the string heap until a collection - 226 MB a Kokoro load, 77 MB a Pocket load. It is written into one build_string writer now: the same text, so the same fingerprint, and every image on disk stays valid. test_layout_fingerprint prints the Model closure a second time and holds the string heap within 256 KB of where it stood.
aleksisch
force-pushed
the
aleksisch/dasllama-load-leaks
branch
from
November 25, 2026 18:53
8826ed9 to
61a71a0
Compare
stream_whisper_model's WhisperStaging was a plain local, so every load left the staged planes on the heap until a collection: 1.6 MB of garbage a Whisper base load. force_inscope_pod does not cover it - the staging has a user finalize - so the local is inscope by hand. The load leaves 0 KB of heap garbage.
The lattice built a fresh string for every candidate piece it looked up and dropped it, and the encode built a dummy-space copy of its input: 460 bytes of string garbage an encode of a short sentence, 18 KB a Bergamot translate. spm_piece_of is [temp_string_result], so the reclaim pass frees each lookup key; the encode reads its input as an inscope byte array (the space, then the text's bytes) and makes no string. The same mark frees the piece the vocabulary reader rewrites. test_tokenizer_unigram_encode_no_garbage holds twenty encodes to the string heap one left (+9200 bytes before).
aleksisch
force-pushed
the
aleksisch/dasllama-load-leaks
branch
from
November 25, 2026 19:10
61a71a0 to
9001337
Compare
The optimization*.das files, dead_branch_folding and the four rtti uncategorized files that drive the inliner, CSE and fast-math move from tests/language to tests/optimization with their eight helper modules. The AOT build registers the folder as the optimization suite (its files and its module helpers, both in test_aot_subset); the per-PR AOT run, the fast-math runs and the sanitizer sweep take the folder beside tests/language, so the moved tests keep every run they had. The two paths utils/mcp and the lint skip fixture name follow the move.
aleksisch
force-pushed
the
aleksisch/dasllama-load-leaks
branch
4 times, most recently
from
November 25, 2026 20:56
259fb79 to
bfb73f3
Compare
optimizationSink (ast_sink.cpp) moves a one-variable let into the if right after it when only one arm reads the variable and nothing after the if does. The common case is an inlined check: the inliner binds the message argument to a local ahead of the body's if, so a passing check still built its message; sunk, it builds it only when it fails. The initializer and the condition must both be droppable: no side effect and no raise. A reference, inscope or collected local, a move out of storage and an arm that shadows the name stay where they are. The pass runs in the optimizer loop after dead stores. The policy disable_sink turns it off; AST serializer version 289. tests/optimization/optimization_sink.das: 11 tests, interpreted and JIT; 4 fail under -policy disable_sink=true. Full suite: no change in the failure set against the baseline. 1M passing checks: 125-147 ms -> 4 ms interpreted, 91-97 ms -> <1 ms JIT; benchmarks/core+micro and the dasLLAMA loads unchanged.
aleksisch
force-pushed
the
aleksisch/dasllama-load-leaks
branch
from
November 25, 2026 21:01
bfb73f3 to
11c552a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
dasLLAMA heap garbage at load and per call, and a sink pass in the optimizer.
Fixes, measured on the real models under -jit with force_inscope_pod:
(build_string) instead of a += chain.
skips it: a user finalize) - 1.6 MB of heap garbage a base load, now 0.
reads its input as an inscope byte array - 18 KB of string garbage a
Bergamot translate, now 0 (test_tokenizer_unigram_encode_no_garbage,
+9200 bytes on the old code).
Tests: the optimizer's tests move to tests/optimization, registered as
an AOT suite of their own.
Compiler: optimizationSink (ast_sink.cpp, one visitor) moves a let into
the if right after it when all its uses sit in one arm. An inlined check
then builds its message only when it fails: 1M passing checks 118-259 ms
-> 4-25 ms interpreted, 96 ms -> <1 ms JIT. Initializer and condition
must be droppable. Policy disable_sink; AST serializer 289. Tests: 11, 4
fail under disable_sink. Full suite: same 14 failures + 1 error as base.
Compile cost, whole dasLLAMA engine (-compile-only -no-module-cache):
sink 90-96 ms (2.2% of optimizer time; DSE 590, CSE 850-915), ~0.5% of
the ~18 s compile; 2 extra optimizer rounds of 470.
Checks: lint 0, dasfmt, REVIEW.das, line length, tests/optimization
355/355 interpreted, JIT and AOT, tests/language 1943/1943.